<?php
/**
 * Author: Hancock
 * Email: 84622365@qq.com
 * Date: 3/23/2016
 * Des: 启动
 */
include_once('core.tree.php');
//引入核心类
foreach ($paths as $path) {
    include_once(FRAMEWORK_PATH . $path);
}

class Bootstrap
{
    public static $con;
    public static $act;
    private static $config;

    private static function init_db()
    {
        DB::init(DEFAULT_DB_TYPE, self::$config['db']);
    }

    private static function init_cache()
    {
        Cache::init(self::$config['cache']);
    }

    private static function init_view()
    {

    }

    private static function init_con()
    {
//        $_GET['con'] = htmlspecialchars(removeXss($_GET['con']));
        self::$con = isset($_GET['con']) ? $_GET['con'] : DEFAULT_CON;
    }

    private static function init_act()
    {
//        $_GET['act'] = htmlspecialchars(removeXss($_GET['act']));
        self::$act = isset($_GET['act']) ? $_GET['act'] : DEFAULT_ACT;
    }

    private static function init_config()
    {
        $config = Factory::register('Config', 'core');
        self::$config = $config::get();
    }

    public static function run()
    {
        self::init_config();
        self::init_db();
        self::init_cache();
        self::init_act();
        self::init_con();
        if (isset($_SESSION['argv'])) {
            C($_SESSION['argv'][1], $_SESSION['argv'][2]);
        } else {
            C(self::$con, self::$act);
        }
    }
}
